use std::fmt;

// 窗口大小，用于流量控制
pub const WINDOW_ACKNOWLEDGEMENT_SIZE: u32 = 4096;
// 对等带宽
pub const PEER_BANDWIDTH: u32 = 4096;

// 对等带宽限制模块
pub mod peer_bandwidth_limit_type {
    // 硬限制
    pub const HARD: u8 = 0;
    // 软限制
    pub const SOFT: u8 = 1;
    // 动态限制
    pub const DYNAMIC: u8 = 2;
}

// FMS 版本
pub const FMSVER: &str = "FMS/3,0,1,123";
// 能力常量
pub const CAPABILITIES: f64 = 31.0;
// 状态级别
pub const LEVEL: &str = "status";

// AMF0 编码
pub const OBJENCODING_AMF0: f64 = 0.0;
// AMF3 编码
pub const OBJENCODING_AMF3: f64 = 3.0;

// 流 ID
pub const STREAM_ID: f64 = 1.0;

// 连接事务ID
pub const TRANSACTION_ID_CONNECT: u8 = 1;
// 创建流事务ID
pub const TRANSACTION_ID_CREATE_STREAM: u8 = 2;

pub const RTMP_LEVEL_WARNING: &str = "warning";
pub const RTMP_LEVEL_STATUS: &str = "status";
pub const RTMP_LEVEL_ERROR: &str = "error\n";

// 会话类型枚举
pub enum SessionType {
    Client,
    Server,
}

impl fmt::Display for SessionType {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let client_type = match self {
            SessionType::Client => String::from("client"),
            SessionType::Server => String::from("server"),
        };
        write!(f, "{client_type}")
    }
}
